Skip to content

[PWGJE] Fix casts - #18389

Open
vkucera wants to merge 1 commit into
AliceO2Group:masterfrom
vkucera:cast-PWGJE
Open

vkucera wants to merge 1 commit into
AliceO2Group:masterfrom
vkucera:cast-PWGJE

Conversation

@vkucera

@vkucera vkucera commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator

Fixes C-style, redundant, wrong, and dangerous casts (found by Clang-Tidy and cpplint).

  • Remove redundant casts. (readability-redundant-casting)
  • Remove const_cast. (cppcoreguidelines-pro-type-const-cast)
  • Replace C-style casts with static_cast. (google-readability-casting, cpplint: readability/casting)
  • Replace unsafe C-style casts with dynamic_cast. (cppcoreguidelines-pro-type-cstyle-cast)
  • Replace static_cast in downcasts with dynamic_cast. (cppcoreguidelines-pro-type-static-cast-downcast)
  • Replace reinterpret_cast with static_cast or dynamic_cast. (cppcoreguidelines-pro-type-reinterpret-cast)
  • Replace two-step casting through void* with reinterpret_cast. (bugprone-casting-through-void)

@github-actions

github-actions Bot commented Oct 21, 2026 •

Copy link
Copy Markdown

O2 linter results: ❌ 0 errors, ⚠️ 942 warnings, 🔕 25 disabled

@github-actions github-actions Bot added the pwgje label Oct 21, 2026
@github-actions github-actions Bot changed the title Fix casts [PWGJE] Fix casts Oct 21, 2026
@vkucera
vkucera force-pushed the cast-PWGJE branch 4 times, most recently from 0564a8d to 324acd7 Compare October 23, 2026 15:00
Fixes C-style, redundant, wrong, and dangerous casts (found by Clang-Tidy and cpplint).

- Remove redundant casts. (`readability-redundant-casting`)
- Remove `const_cast`. (`cppcoreguidelines-pro-type-const-cast`)
- Replace C-style casts with `static_cast`. (`google-readability-casting`, cpplint: `readability/casting`)
- Replace unsafe C-style casts with `dynamic_cast`. (`cppcoreguidelines-pro-type-cstyle-cast`)
- Replace `static_cast` in downcasts with `dynamic_cast`. (`cppcoreguidelines-pro-type-static-cast-downcast`)
- Replace `reinterpret_cast` with `static_cast` or `dynamic_cast`. (`cppcoreguidelines-pro-type-reinterpret-cast`)
- Replace two-step casting through `void*` with `reinterpret_cast`. (`bugprone-casting-through-void`)
@vkucera
vkucera marked this pull request as ready for review October 23, 2026 15:07
@alibuild

Copy link
Copy Markdown
Collaborator

Error while checking build/O2Physics/code-check for a1ccb99 at 2026-10-23 18:23:

## sw/BUILD/O2Physics-code-check-latest/log
--
========== List of issues found ==========
++ echo 'To reproduce the results below locally, run: '\''aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'\''.'
To reproduce the results below locally, run: 'aliBuild build O2Physics-code-check -e ALIBUILD_BASE_HASH=upstream/master'.
++ echo 'To apply all automatic fixes, add the '\''-e O2PHYSICS_CHECKER_FIX=1'\'' option.'
To apply all automatic fixes, add the '-e O2PHYSICS_CHECKER_FIX=1' option.
++ echo 'See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.'
See the documentation for more details at: <https://aliceo2group.github.io/analysis-framework/docs/tools/#running-with-o2physics-code-check>.
++ echo 'Found 27 errors and 516 warnings.'
Found 27 errors and 516 warnings.
++ [[ 27 -gt 0 ]]
++ cat /sw/BUILD/a47ed0653e91787557d9c4993e86e3f09a399475/O2Physics-code-check/errors.txt
PWGJE/Core/JetFindingUtilities.h:41:1: error: included header utility is not used directly [misc-include-cleaner,-warnings-as-errors]
PWGJE/DataModel/Jet.h:181:1: error: Called C++ object pointer is null [clang-analyzer-core.CallAndMessage,-warnings-as-errors]
PWGJE/Tasks/fullJetSpectra.cxx:1384:7: error: Value stored to 'eventAccepted' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGJE/Tasks/fullJetSpectra.cxx:1388:7: error: Value stored to 'eventAccepted' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGJE/Tasks/fullJetSpectra.cxx:1393:7: error: Value stored to 'eventAccepted' is never read [clang-analyzer-deadcode.DeadStores,-warnings-as-errors]
PWGJE/Tasks/jetFinderQA.cxx:1296:13: error: Variable 'pt' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter,-warnings-as-errors]
PWGJE/Tasks/jetFinderQA.cxx:1302:13: error: Variable 'pt' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter,-warnings-as-errors]
PWGJE/Tasks/jetFinderQA.cxx:1308:13: error: Variable 'pt' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter,-warnings-as-errors]
PWGJE/Tasks/jetHadronRecoil.cxx:321:9: error: Variable 'shift' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter,-warnings-as-errors]
PWGJE/Tasks/jetHadronRecoil.cxx:374:11: error: Variable 'shift' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter,-warnings-as-errors]
PWGJE/Tasks/jetHadronRecoil.cxx:378:11: error: Variable 'shift' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter,-warnings-as-errors]
PWGJE/Tasks/jetHadronRecoil.cxx:460:9: error: Variable 'shift' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter,-warnings-as-errors]
PWGJE/Tasks/jetHadronRecoil.cxx:512:11: error: Variable 'shift' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter,-warnings-as-errors]
PWGJE/Tasks/jetHadronRecoil.cxx:516:11: error: Variable 'shift' with floating point type 'double' should not be used as a loop counter [clang-analyzer-security.FloatLoopCounter,-warnings-as-errors]
PWGJE/Tasks/jetSubstructureHFOutput.h:729:15: error: loop variable is copied but only used as const reference; consider making it a const reference [performance-for-range-copy,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:633:33: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:633:74: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:633:114: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:633:158: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:634:32: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:634:72: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:634:111: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:634:154: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:635:34: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:635:76: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:635:117: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
PWGJE/Tasks/jetTaggerHFQA.cxx:635:162: error: variable length arrays in C++ are a Clang extension [clang-diagnostic-vla-cxx-extension,-warnings-as-errors]
++ [[ 516 -gt 0 ]]
++ cat /sw/BUILD/a47ed0653e91787557d9c4993e86e3f09a399475/O2Physics-code-check/warnings.txt
PWGJE/Core/JetFindingUtilities.h:44:10: warning: inclusion of deprecated C++ header 'math.h'; consider using 'cmath' instead [modernize-deprecated-headers]
PWGJE/Core/JetFindingUtilities.h:269:12: warning: redundant boolean literal in conditional return statement [readability-simplify-boolean-expr]
PWGJE/Core/JetFindingUtilities.h:270:5: warning: do not use 'else' after 'return' [readability-else-after-return]
PWGJE/Core/JetFindingUtilities.h:350:82: warning: repeated branch body in conditional chain [bugprone-branch-clone]
PWGJE/Core/JetFindingUtilities.h:352:7: warning: do not use 'else' after 'continue' [readability-else-after-return]
PWGJE/Core/JetFindingUtilities.h:411:5: warning: do not use 'else' after 'return' [readability-else-after-return]
PWGJE/Core/JetTaggingUtilities.h:235:5: warning: do not use 'else' after 'return' [readability-else-after-return]
[0 more errors; see full log]

Full log here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants